import requests,json,time
from 核心.配置文件 import settings
from 核心.获取token import get_token

class Comm:

    ##初始化
    def __init__(self):
        self.token = get_token()


    def get_resp(self, url):
        payload = {}
        # 使用动态时间戳
        current_timestamp = int(time.time() * 1000)
        headers = {
            'accept': 'application/json, text/plain, */*',
            'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
            'authorization': 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMTYzMTA3NyIsImlzcyI6IiIsImlhdCI6MTc1NjE5MTQyNCwibmJmIjoxNzU2MTkxNDI0LCJleHAiOjE5MTM4NzE0MjR9.31GlXOHvBEjKqJlvcdYmtxH6tR88ua0Z3Yf77ig9M9U',
            'cache-control': 'no-cache',
            'deviceid': 'h5_a5be7aa1_850a_469b_8f94_40892',
            'pragma': 'no-cache',
            'priority': 'u=1, i',
            's': '7c4797ad736d4598201ba34250d17c99',
            'sec-fetch-dest': 'empty',
            'sec-fetch-mode': 'cors',
            'sec-fetch-site': 'same-origin',
            't': str(current_timestamp),  # 使用动态时间戳
            'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1',
            'user-mark': 'xhp'
        }

        if self.token:
            headers['authorization'] = self.token

        response = requests.request("GET", url, headers=headers, timeout=30)
        return response
comm = Comm()